package fr.alesia.capitale.servlet;

import java.io.IOException;
import java.util.SortedSet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import fr.alesia.capitale.Capitales;
import fr.alesia.capitale.bean.Pays;
import fr.alesia.capitale.dao.PaysDao;
import fr.alesia.capitale.factory.DaoFactory;

@SuppressWarnings("serial")
public class RevisionServlet extends HttpServlet {
	
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		
		ServletContext context = this.getServletContext();
		
		PaysDao dao = DaoFactory.getPaysDao();
		SortedSet<Pays> pays = dao.getAll();
		request.setAttribute("pays", pays);
		
		RequestDispatcher dispatcher = context.getRequestDispatcher(Capitales.PAGES + "/revision.jsp");
		dispatcher.forward(request, response);
	}
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		
		this.doPost(request, response);
	}
}
